import React from 'react';
import { useRequest, defaultFormatResult } from '@/hooks';
import { getCandidateInfo } from '../service/hire';

const useInterviewCandidate = signCandidateId => {
    // const push = path => {
    //     try {
    //         history.push({
    //             pathname: path,
    //             query: {
    //                 id: signCandidateId
    //             }
    //         });
    //     } catch (error) {
    //         window.location.href = `${window.location.origin}${path}?id=${signCandidateId}`;
    //     }
    // };

    const { data, loading, run: fetchDetail } = useRequest(() => getCandidateInfo(signCandidateId), {
        manual: true,
        initialData: null,
        ...defaultFormatResult
    });

    React.useEffect(() => {
        if (signCandidateId) {
            fetchDetail(signCandidateId);
        }
    }, [signCandidateId]);

    return {
        data,
        loading,
        fetchDetail
    };
};

export default useInterviewCandidate;
